require 'java'
Dir["/Users/riccardotacconi/dev/rsigar/*.jar"].each { |jar| require jar }
import com.hazelcast.core.Hazelcast
import com.hazelcast.core.MembershipListener

cluster = Hazelcast.getCluster()

cluster.add_membership_listener(MembershipListener.impl do |method, evt|
  puts 'Type event: '+evt.class
  member = evt.get_member
  puts 'IP address of the node: '+member.getInetAddress.to_s
  case method.to_s
    when "memberAdded"
      puts 'Event: join member'
    when "memberRemoved"
        puts 'Event: lost member'
  end
end)